package org.nlp2rdf.navigator.benchmark;

import org.aksw.commons.util.collections.TransformCollection;
import org.apache.commons.collections15.Transformer;

/**
 * Created by Claus Stadler
 * Date: Oct 12, 2010
 * Time: 5:50:43 PM
 */
public class WrapperGenericLearner<I, O, D>
    implements IGenericLearner<I, D>
{
    private IGenericLearner<O, D> decoratee;
    private Transformer<I, O> transformer;


    public WrapperGenericLearner(IGenericLearner<O, D> decoratee, Transformer<I, O> transformer)
    {
        this.decoratee = decoratee;
        this.transformer = transformer;
    }

    @Override
    public D learn(Sample<I> sample)
            throws Exception
    {
        Sample<O> tmp = Sample.createCopy(
                new TransformCollection<I, O>(sample.getPositives(), transformer),
                new TransformCollection<I, O>(sample.getNegatives(), transformer));

        return decoratee.learn(tmp);
    }
}